//
//  CZQHomeTableViewCell.m
//  Project_A
//
//  Created by dlios on 15-7-13.
//  Copyright (c) 2015年 zhoukaidong. All rights reserved.
//

#import "CZQHomeTableViewCell.h"
#import "CZQHomeModel.h"
#import "UIImageView+WebCache.h"

#define WIDTH self.contentView.frame.size.width / 375
#define HEIGHT self.contentView.frame.size.height / 200

@implementation CZQHomeTableViewCell

- (void)dealloc
{
    [_titieLabel release];
    [_titleImg release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.titleImg = [[[UIImageView alloc] init] autorelease];
        [self.contentView addSubview:self.titleImg];
        
        self.blackImg = [[[UIImageView alloc] init] autorelease];
        self.blackImg.alpha = 0.4;
        [self.contentView addSubview:self.blackImg];
        
        self.titieLabel = [[[UILabel alloc] init] autorelease];
        self.titieLabel.textColor = [UIColor whiteColor];
        [self.titieLabel setFont:[UIFont systemFontOfSize:20]];
        [self.contentView addSubview:self.titieLabel];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.titleImg.frame = CGRectMake(5 * WIDTH, 5 * HEIGHT, 365 * WIDTH, 190 * HEIGHT);
    self.blackImg.frame = CGRectMake(5 * WIDTH, 155 * HEIGHT, 365 * WIDTH, 40 * HEIGHT);
    self.titieLabel.frame = CGRectMake(15 * WIDTH, 160 * HEIGHT, 345 * WIDTH, 30 * HEIGHT);
}

- (void)setModel:(CZQHomeModel *)model
{
    if (model != _model) {
        [_model release];
        _model = [model retain];
    }
    self.titieLabel.text = model.title;
    [self.titleImg setImageWithURL:[NSURL URLWithString:model.cover_image_url]];
    self.blackImg.image = [UIImage imageNamed:@"FR13%@UDX{MB90%ARENMOEC.jpg"];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
